//新闻分类刷新页面
layui.config({
	base : "js/data/"
}).use(['allApi'],function(){
	var allApi = layui.allApi;
	//获取所有分类
	allApi.dataListF(allApi.article_cat,"data-cat","cat-list");
	//初始化获取不同数据
	var ulList=$(".news-list");
	ulList.each(function(){
		var catId=$(this).attr("data-id");
		allApi.dataListLoad(catId,"#news-list"+catId,allApi.article,"data-list");
	})
	//切换分类
	$(document).on("click",".slide",function(){
		if(!$(this).hasClass("active")){
			$(".slide").removeClass("active");
            $(".add-active").removeClass("now");
            $(this).addClass("active");
            $(this).children().addClass("now");
			var id=$(this).attr('data-id');
			$(".news-list").hide();
			$("#news-list"+id).show();
		}
	})
	allApi.linkEvent("#news-lists","li");
	var mySwiper = new Swiper('.swiper-container', {
		slidesPerView : 3,
		slidesPerGroup : 3,
		onTransitionEnd: function(swiper){
		  if(swiper.progress==1){
			  swiper.activeIndex=swiper.slides.length-1
		  }
      	}
	})
})